﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Chenxin.Lib.Utility;

public partial class PublishInfo_InfoPublish : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string RecordId = Context.Request.Params["RecordId"];
            if (!string.IsNullOrEmpty(RecordId))
            {
                //公共信息
                Chenxin.Lib.Hr.Entity.Pblish_Info entInfo = Chenxin.Lib.Hr.BLL.Pblish_Info.GetModel(new Guid(RecordId));

                //权限判断
                //if (entInfo.PublisherId != CurrentUserInfo.UserId)
                //{

                //    Context.Response.Redirect(string.Format("/errorpage.aspx?msg={0}", "没有编辑此公共信息的权限"));
                //}

                entInfo.Content = Server.UrlDecode(entInfo.Content);
                hidInfo.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(entInfo);

                //附件
                DataSet ds = Chenxin.Lib.Hr.BLL.Attachment.GetListByBelong(RecordId, 30);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string localPath = "/service/Download.ashx?file=" + ds.Tables[0].Rows[0]["Path"].ToString();
                    ltFile.Text = string.Format("<div><input id=\"chkFile\" name=\"chkFile\" type=\"checkbox\" value=\"{0}\" /><a href=\"{2}\" target=\"blank\">{1}</a></div>", ds.Tables[0].Rows[0]["RecordId"], ds.Tables[0].Rows[0]["FileName"], localPath);
                }
            }
        }
        catch (Exception ex)
        {
            Context.Response.Redirect("/errorpage.aspx?msg=" + ex.Message);
        }
    }
}
